# Samba file sharing ***Copyright © Quectel Wireless Solutions Co., Ltd. 2026. All rights reserved.*** --- # Overview Samba is a commonly used tool for building file sharing and access control services on Linux systems. It uses the SMB protocol to enable file access between different devices within a local area network. By deploying Samba locally, you can easily provide shared directories to Windows, Linux, or macOS clients, enabling cross-platform file transfer and collaboration. This document describes how to configure a Samba file sharing service on the Quectel Pi M2 Debian system so that a Windows computer can directly access the device's shared folders. # Prerequisites 1. Confirm the device environment: - Quectel Pi M2 has booted into the Debian system - The Windows host and the device are on the same local area network with working network connectivity - M2 is verified under the GNOME graphical environment. Samba file sharing does not depend on the GNOME desktop. 2. Check network connectivity.Run the following command on the device to view the current IP address: ```bash hostname -I ``` ```powershell ping ``` # Install Samba Service Samba is a service program on Debian/Linux used for sharing files with Windows systems. 1. Update the package list: ```bash sudo apt-get update ``` 2. Install Samba and client tools: ```bash sudo apt-get install -y samba smbclient ``` > 💡 **`samba`**: Server-side software for providing sharing services; **`smbclient`**: Client tool that can be used to test whether the connection is successful. 3. Confirm that Samba is installed successfully: ```bash smbd --version smbclient --version ``` # Create a Shared Folder > 💡 This document uses the user `q` as an example to illustrate Samba sharing configuration. If this user does not yet exist in the system, you can use an existing user (such as `root`), or create a regular user first before proceeding with the configuration. 1. Create a shared directory: ```bash mkdir -p /home/q/share ``` 2. Create a test file: ```bash touch /home/q/share/test.txt ``` 3. Modify permissions: ```bash sudo chown -R q:q /home/q/share chmod -R 775 /home/q/share ``` # Configure Samba Service 1. Open the configuration file: ```bash sudo vim /etc/samba/smb.conf ``` ```bash sudo nano /etc/samba/smb.conf ``` 2. Scroll to the end of the file and add the following content: ``` [myshare] comment = My Shared Folder browseable = yes path = /home/q/share create mask = 0664 directory mask = 0775 valid users = q force user = q force group = q public = no guest ok = no writable = yes available = yes ``` > 💡 **`[myshare]`** — The share name seen by Windows clients when accessing. **`path`** — The actual path of the shared directory. **`create mask / directory mask`** — Default permissions for newly created files/folders. **`valid users`** — Authorized users allowed to access the Samba server; the example user here is `q`; in actual use, replace it with the real user on the development board. **`writable = yes`** — Allows clients to create, modify, and delete files in this directory. > 💡 If you need to allow anonymous access, use `public = yes`; if you need to prevent anonymous/guest access, keep `public = no, guest ok = no`. 3. Check the Samba configuration file syntax: ```bash testparm ``` # Set Samba User and Password The Samba login user must be an existing user in the system and requires a separate Samba access password. Using the system user `q` as an example: ```bash sudo smbpasswd -a q ``` You will need to enter the password twice for confirmation (this password will be used when accessing from Windows). # Restart Samba Service to Apply Configuration ```bash sudo systemctl restart smbd sudo systemctl status smbd --no-pager -l ``` Set Samba to start automatically on boot: ```bash sudo systemctl enable smbd ``` # Check Port Listening Samba primarily uses TCP port 445. After the service starts, run the following command to confirm whether the port is in a listening state: ```bash ss -tulnp | grep -E ':445|:139' ``` If the device has a firewall enabled, allow TCP port 445 according to your actual firewall tool. When no firewall is enabled, no additional rules are needed. # View Device IP Address Before accessing the device's shared directory from Windows, you need to obtain the device IP address: ```bash hostname -I ``` In actual use, use the IP address currently queried on the development board. # Access Device Shared Folder from Windows Computer 1. Run the following command on the Quectel Pi M2 device to obtain the development board IP address: ```bash hostname -I ``` 2. Open **Command Prompt** on the Windows host and run the following commands to connect to the shared directory: ``` net use \\\myshare /delete net use \\\myshare /user:q explorer \\\myshare ``` 3. After successful access, you will see the previously created test file `test.txt`. > 💡 If Windows reports that access is not possible, first run `ping ` to confirm network reachability. If credentials conflict, delete the device-related credentials in the Windows "Credential Manager" and reconnect. # Access Windows Shared Folder from the Device In addition to accessing the device's shared directory from a Windows computer, you can also reverse access a shared folder on a Windows computer from the device. ## Create a Shared Directory on Windows 1. Create a new folder for sharing on the Windows computer, for example: ``` device_share ``` 2. Right-click the folder and select "**Properties**" → "**Sharing**" → "**Advanced Sharing**". 3. Check "**Share this folder**" and set the share name to: ``` m2_share ``` 4. Click "**Permissions**" and add read or write permissions for the Windows users who need to access this shared directory. 5. Switch to the "**Security**" tab and confirm that the Windows user also has the corresponding read or write permissions in NTFS permissions. > 💡 Windows sharing permissions and "Security" permissions must both allow access; otherwise, the device side may be able to see the share name but cannot enter the directory or create files. ## Confirm Network and Firewall on Windows 1. Confirm that the Windows computer and the device are on the same reachable network. 2. Enable the following in Windows "Advanced sharing settings": - Network discovery - File and printer sharing 3. Confirm that the Windows firewall allows "File and Printer Sharing (SMB-In)". ## Check Connectivity from the Device Run the following commands in the device terminal to confirm that the Windows host's SMB service port is accessible (replace `` with the actual IP): ```bash # View the device's current IP address hostname -I # Test network connectivity to Windows host ping -c 3 # Test SMB port connectivity timeout 3 bash -c 'cat < /dev/null > /dev/tcp//445' && echo 445_open || echo 445_failed timeout 3 bash -c 'cat < /dev/null > /dev/tcp//139' && echo 139_open || echo 139_failed ``` If the output shows `445_open` or `139_open`, the device can reach the Windows SMB service port. ## Access from Device via Command Line Use `smbclient` to view the list of shares on the Windows host: ```bash smbclient -L // -U 'DOMAIN\username' ``` Enter the Windows user's login password when prompted. If authentication succeeds, you can see the shared directory names in the output, for example: ``` m2_share Disk ``` Access a specified shared directory and list files: ```bash smbclient /// -U 'DOMAIN\username' -c 'ls' ``` This document confirms that the device can successfully list the Windows host's shared list and enter the corresponding shared directory. ## Access from Device via Graphical Interface > 💡 This method is applicable to the GNOME graphical environment. In the Quectel Pi M2 Debian graphical environment, you can access Windows shared directories through the file manager. Enter the following in the file manager address bar: ``` smb:/// ``` Then follow the on-screen prompts to enter the Windows username, domain or workgroup, and password to access the shared directory.